<template>
	<view>
		<view class="order-detail-head">
			<view class="order-detail-head-item">
				<view>就诊人</view>
				<view>{{user.name}}</view>
			</view>
			<view class="order-detail-head-item">
				<view>证件号</view>
				<view>{{user.certificateId}}</view>
			</view>
		</view>
		<view class="line"></view>
		<view>
			<uni-table stripe="true">
				<uni-tr>
					<uni-th align="center" width="50px">项目名称</uni-th>
					<uni-th align="center" width="30px">单价(元)</uni-th>
					<uni-th align="center" width="30px">数量</uni-th>
					<uni-th align="center" width="30px">金额(元)</uni-th>
				</uni-tr>
				<uni-tr>
					<uni-td>{{collection[0]}}</uni-td>
					<uni-td align="center">{{collection[1]}}.00</uni-td>
					<uni-td align="center">1.00</uni-td>
					<uni-td align="center">{{collection[1]}}.00</uni-td>
				</uni-tr>
			</uni-table>
		</view>
		<view class="order-footer">
			<view class="order-footer-item1">总额:<text style="color: #F0AD4E;">￥{{collection[1]}}.00</text></view>
			<view class="order-footer-item2" @click="gotoCashier">去缴费</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				hospId:-1,
				timeId:-1,
				type:-1,
				chooseMonth:-1,
				chooseDay:-1,
				certificateId:null,
				user:null,
				collection:null
			};
		},
		onLoad(options) {
			this.hospId = options.hospId
			this.type = options.type
			this.chooseMonth = options.chooseMonth
			this.chooseDay = options.chooseDay
			this.certificateId = options.certificateId
			this.timeId = options.timeId
			console.log(this.hospId+","+this.type+","+this.chooseMonth+","+this.chooseDay+","+this.certificateId)
		},
		mounted() {
			this.getCollection()
			this.getUser()
		},
		methods:{
			//获取用户选择的核检类型
			getCollection(){
				uni.request({
					url:'http://192.168.43.224:9002/api/business/getCollectionType/'+this.type,
					method:'GET',
					success: (res) => {
						console.log(res)
						this.collection = res.data.data
						console.log(this.collection[0])
						console.log(this.collection[1])
					}
				})
			},
			
			//根据证件号获取用户信息
			getUser(){
				uni.request({
					url:'http://192.168.43.224:9002/user/getUserByCertificateId/'+this.certificateId,
					method:'GET',
					success: (res) => {
						this.user = res.data.data
					}
				})
			},
			
			//去缴费
			gotoCashier(){
				uni.navigateTo({
					url:'/subpkg/cashier/cashier?'+
					'hospId='+this.hospId+
					'&type='+this.type+
					'&chooseMonth='+this.chooseMonth+
					'&chooseDay='+this.chooseDay+
					'&certificateId='+this.certificateId+
					'&timeId='+this.timeId
				})
			}
		}
	}
</script>

<style lang="scss">
.order-detail-head{
	background-color: #FFFFFF;
	height: 80px;
	.order-detail-head-item{
		padding-top: 15px;
		padding-left: 10px;
		padding-right: 10px;
		display: flex;
		justify-content: space-between;
	}
}
.line{
	display: block;
	background: #40E0D0;
	width: 100%;
	height: 5rpx;
	margin-top: 10px;
}
.order-footer{
	position: fixed;
	bottom: 5px;
	display: flex;
	.order-footer-item1{
		height: 50px;
		background-color:#FFFFFF;
		width: 250px;
		line-height: 50px;
		padding-left: 15px;
	}
	.order-footer-item2{
		height: 50px;
		background-color: #40E0D0;
		width: 90px;
		line-height: 50px;
		padding-left: 15px;
		text-align: center;
	}
}
</style>
